﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LibRadiant.Main;
using Utilities;
using LibRadiant.IO;

namespace LibRadiant
{
    public partial class D3D9RenderingPanel : UserControl
    {
        D3D9Core mCore;

        

        DxTimer mCoreTimer = new DxTimer("CoreTimer");
        public D3D9Core RenderCore
        {
            get { return mCore; }
        }

        public IOManager IOManager
        {
            get { return mCore.IOManager; }
        }

        public D3D9RenderingPanel()
        {
            InitializeComponent();
            mCore = new D3D9Core(Handle, Width, Height);
        }

        public void UpdateRender()
        {
            mCore.Update(mCoreTimer.ElaspedTime(true));
        }

        #region Handle mouse events
        private void D3D9RenderingPanel_MouseDown(object sender, MouseEventArgs e)
        {
            mCore.IOManager.FireMouseDownEvent(sender, e);
        }

        private void D3D9RenderingPanel_MouseMove(object sender, MouseEventArgs e)
        {
            mCore.IOManager.FireMouseMoveEvent(sender, e);
        }

        private void D3D9RenderingPanel_MouseUp(object sender, MouseEventArgs e)
        {
            mCore.IOManager.FireMouseUpEvent(sender, e);
        }
        #endregion


        #region Handle keyboard events

        private void D3D9RenderingPanel_KeyDown(object sender, KeyEventArgs e)
        {
            mCore.IOManager.FireKeyDownEvent(sender, e);
        }

        private void D3D9RenderingPanel_KeyUp(object sender, KeyEventArgs e)
        {
            mCore.IOManager.FireKeyUpEvent(sender, e);
        }
        #endregion

    }
}
